Always build with '-pedantic'
authorSandrine Bailleux <[email protected]>
Mon, 4 Jan 2016 15:49:23 +0000 (15:49 +0000)
committerSandrine Bailleux <[email protected]>
Tue, 5 Jan 2016 11:41:08 +0000 (11:41 +0000)
By default ARM TF is built with the '-pedantic' compiler flag, which
helps detecting violations of the C standard. However, the mbed TLS
library and its associated authentication module in TF used to fail
building with this compiler flag. As a workaround, the mbed TLS
authentication module makefile used to set the 'DISABLE_PEDANTIC'
TF build flag.

The compiler errors flagged by '-pedantic' in the mbed TLS library
have been fixed between versions 1.3.9 and 2.2.0 and the library now
properly builds with this compiler flag.

This patch fixes the remaining compiler errors in the mbed TLS
authentication module in TF and unsets the 'DISABLE_PEDANTIC' TF
build flag. This means that TF is now always built with '-pedantic'.

In particular, this patch:

 * Removes the final semi-colon in REGISTER_COT() macro.

   This semi-colon was causing the following error message:

   drivers/auth/tbbr/tbbr_cot.c:544:23: error: ISO C does not allow
   extra ';' outside of a function [-Werror=pedantic]

   This has been fixed both in the mbed TLS authentication module
   as well as in the certificate generation tool. Note that the latter
   code didn't need fixing since it is not built with '-pedantic' but
   the change has been propagated for consistency.

   Also fixed the REGISTER_KEYS() and REGISTER_EXTENSIONS() macros,
   which were suffering from the same issue.

 * Fixes a pointer type.

   It was causing the following error message:

   drivers/auth/mbedtls/mbedtls_crypto.c: In function 'verify_hash':
   drivers/auth/mbedtls/mbedtls_crypto.c:177:42: error: pointer of
   type 'void *' used in arithmetic [-Werror=pointer-arith]

Change-Id: I7b7a04ef711efd65e17b5be26990d1a0d940257d

drivers/auth/mbedtls/mbedtls_common.mk
drivers/auth/mbedtls/mbedtls_crypto.c
include/drivers/auth/auth_mod.h
tools/cert_create/include/cert.h
tools/cert_create/include/ext.h
tools/cert_create/include/key.h

index bc381d5e425a04804b0961257e7958ce6e84f434..5186f16f3daf8e4c3d64283880aaa6116bb6a7c0 100644 (file)
@@ -55,6 +55,5 @@ MBEDTLS_COMMON_SOURCES        :=      drivers/auth/mbedtls/mbedtls_common.c   \
 
 BL1_SOURCES            +=      ${MBEDTLS_COMMON_SOURCES}
 BL2_SOURCES            +=      ${MBEDTLS_COMMON_SOURCES}
-DISABLE_PEDANTIC       :=      1
 
 endif
index 6a898ddc8584a19ffb42ca6132c1437bc2ef3b83..1a96e8f8d0cb54f72ceb63bc311402867a5269d1 100644 (file)
@@ -174,7 +174,7 @@ static int verify_hash(void *data_ptr, unsigned int data_len,
 
        /* Digest info should be an MBEDTLS_ASN1_SEQUENCE */
        p = (unsigned char *)digest_info_ptr;
-       end = (unsigned char *)(digest_info_ptr + digest_info_len);
+       end = p + digest_info_len;
        rc = mbedtls_asn1_get_tag(&p, end, &len, MBEDTLS_ASN1_CONSTRUCTED |
                                  MBEDTLS_ASN1_SEQUENCE);
        if (rc != 0) {
index 0f19b5c4c75b7eb8c45536883674d1ecc1ce8c05..c00b2565adc97410af8672660a40d885411db37d 100644 (file)
@@ -65,7 +65,7 @@ int auth_mod_verify_img(unsigned int img_id,
 #define REGISTER_COT(_cot) \
        const auth_img_desc_t *const cot_desc_ptr = \
                        (const auth_img_desc_t *const)&_cot[0]; \
-       unsigned int auth_img_flags[sizeof(_cot)/sizeof(_cot[0])];
+       unsigned int auth_img_flags[sizeof(_cot)/sizeof(_cot[0])]
 
 #endif /* TRUSTED_BOARD_BOOT */
 
index 11381c93c8ed8070be734f6d0eb01d817f1b2fa9..8ef9f27310d6bc272f138563d96bd61408347082 100644 (file)
@@ -76,7 +76,7 @@ int cert_new(cert_t *cert, int days, int ca, STACK_OF(X509_EXTENSION) * sk);
 /* Macro to register the certificates used in the CoT */
 #define REGISTER_COT(_certs) \
        cert_t *certs = &_certs[0]; \
-       const unsigned int num_certs = sizeof(_certs)/sizeof(_certs[0]);
+       const unsigned int num_certs = sizeof(_certs)/sizeof(_certs[0])
 
 /* Exported variables */
 extern cert_t *certs;
index 0ede365181e219d85665b037a999e67b2c121dd3..798bd1be2eaf021df8c9ed02101ef401c43cc4c6 100644 (file)
@@ -92,7 +92,7 @@ X509_EXTENSION *ext_new_key(int nid, int crit, EVP_PKEY *k);
 /* Macro to register the extensions used in the CoT */
 #define REGISTER_EXTENSIONS(_ext) \
        ext_t *extensions = &_ext[0]; \
-       const unsigned int num_extensions = sizeof(_ext)/sizeof(_ext[0]);
+       const unsigned int num_extensions = sizeof(_ext)/sizeof(_ext[0])
 
 /* Exported variables */
 extern ext_t *extensions;
index 6995a06339768f9e136dc17abb2a97cfad5e7a1a..bd45f13436b24408bf926645af49fc1eb94fd417 100644 (file)
@@ -79,7 +79,7 @@ int key_store(key_t *key);
 /* Macro to register the keys used in the CoT */
 #define REGISTER_KEYS(_keys) \
        key_t *keys = &_keys[0]; \
-       const unsigned int num_keys = sizeof(_keys)/sizeof(_keys[0]);
+       const unsigned int num_keys = sizeof(_keys)/sizeof(_keys[0])
 
 /* Exported variables */
 extern key_t *keys;